<template>
  <div>
    <h1 style="color: #ea3200;position: relative;">欢迎登录</h1>
    <h2 style="color: #ea3200;position: relative;">Welcome to Student Book Store</h2>

      <div style="width: 380px;height: 500px;margin-left: 35%;text-align: center">
        <img src="/images/reg_logo.jpg.jpg" alt="" title="欢迎来到学子书城" style="width: 200px;margin-left: 160px">
        <el-menu router :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect" style="margin-left: 140px;width:245px">
          <el-menu-item index="/account-login">账号密码登录</el-menu-item>
          <el-menu-item index="/phone-login">手机号登录</el-menu-item>
        </el-menu>
        <router-view/>

      </div>

    <p>Copyright © 2015-2022 学子书城电子商务有限责任公司 版权所有</p>
    <div style="text-align: center;">
      <el-link href="/student-bookstore">商城首页（临时，不需要登录即可跳转）</el-link>
    </div>
  </div>
</template>
<style>
.button {
  background-color: #ea3200;
  border: none;
}
.button:hover{
  background-color: #ea7479;
}
.button:focus{
  background-color: #ea7479;
}

</style>
<script>
export default {
  data() {
    return {
      activeIndex: '/account-login',
      activeIndex2: '/phone-login',

      check: {checkCode: ''},
      getCheck: {getCode: ''},
      ruleForm: {
        username: '',
        password: '',
        phoneNum: '',

      },
      rules: {
        username: [
          {required: true, message: '请输入用户名', trigger: 'blur'},
          {min: 4, max: 18, message: '长度在 6 到 18 个字符', trigger: 'blur'},
          {pattern: /^[a-zA-Z]\w{5,17}$/, message: '必须以字母开头,只能包含字符,数字的6-18位字符。'}
        ],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
          {pattern: /^[A-Za-z0-9]{6,12}$/, message: "必须是英文或者数字，并且长度为6-12个字符"}
        ],
        phoneNum: [
          {required: true, message: '请输入手机号', trigger: 'blur'},
          {pattern: /^[1][3,4,5,7,8][0-9]{9}/, message: '请输入正确的手机号'},
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          if (this.check.checkCode==this.getCheck.getCode){
            console.log("信息正确功能还没做")
          }else {
            console.log("获得到的验证码"+this.getCheck.getCode)
            console.log("输入的验证码"+this.check.checkCode)
            this.$message.error("验证码错误！")
          }

        } else {
          this.$message.error("请检查您的输入信息！")
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
    getCode() {
      let url="http://localhost:9080/SMS/check";
      this.axios.get(url+"?phoneNum="+this.ruleForm.phoneNum).then((response) => {
        this.getCheck.getCode = response.data.data
        console.log(response)
      })
    },
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    }
  }
}
</script>

<style scoped>

</style>